Emmett Stralka - Engineering Portfolio
  • Home
  • Projects
  • Resume
  • Labs
  • Resources
  • About

Lab 1: Board Assembly and Testing

embedded-systems
hardware-setup
lab-report
Initial setup and testing of the microcontroller development board, establishing the foundation for embedded systems development
Author

Emmett Stralka

Published

August 29, 2024

Lab 1: Board Assembly and Testing

Initial setup and testing of the microcontroller development board, establishing the foundation for embedded systems development


Overview

Lab 1 focuses on the initial setup and testing of the microcontroller development board, establishing the foundation for embedded systems development. This lab introduces students to the hardware components, development environment, and basic testing procedures essential for successful completion of subsequent labs.

Learning Objectives

  • Understand the layout and components of the microcontroller development board
  • Safely assemble the board, including connecting peripherals and power
  • Perform initial power-on and functional tests
  • Set up the development environment for basic code deployment
  • Troubleshoot common hardware assembly issues

Step-by-Step Procedure

1. Component Identification

  • Identify key components: Microcontroller unit (MCU), power regulators, crystal oscillators, GPIO pins, USB interface, and debugging headers
  • Refer to the board’s schematic and datasheet for detailed information

2. Board Assembly

  • Carefully connect all necessary headers and jumpers
  • Ensure all components are seated correctly to prevent short circuits or damage
  • Connect the USB cable for power and data

3. Power-On Self-Test (POST)

  • Connect the board to a power source
  • Observe LED indicators for power and status
  • Use a multimeter to verify correct voltage levels at critical points (e.g., 3.3V, 5V rails)

4. Driver Installation and IDE Setup

  • Install necessary USB drivers for the microcontroller
  • Set up the integrated development environment (IDE) (e.g., VS Code with PlatformIO, Keil uVision, or similar)
  • Configure the toolchain for the specific microcontroller architecture

5. First Program: Blinky LED

  • Write a simple program to toggle an onboard LED
  • Compile the code and flash it to the microcontroller
  • Verify that the LED blinks as expected. This confirms the toolchain, programmer, and basic board functionality
#include <stdint.h>

#define LED_PIN (1 << 5) // Example: LED connected to GPIO Pin 5
#define GPIO_PORT_BASE 0x40020000 // Example: Base address for GPIO Port A
#define GPIO_DIR_REG *(volatile uint32_t *)(GPIO_PORT_BASE + 0x04) // Direction Register
#define GPIO_OUT_REG *(volatile uint32_t *)(GPIO_PORT_BASE + 0x14) // Output Data Register

void delay(volatile uint32_t count) {
    while (count--);
}

int main(void) {
    // Set LED pin as output
    GPIO_DIR_REG |= LED_PIN;

    while (1) {
        // Turn LED on
        GPIO_OUT_REG |= LED_PIN;
        delay(1000000); // Adjust for desired delay

        // Turn LED off
        GPIO_OUT_REG &= ~LED_PIN;
        delay(1000000); // Adjust for desired delay
    }
}

Technical Implementation

The “Blinky LED” program serves as the “Hello World” of embedded systems. It involves: - GPIO Configuration: Setting a General Purpose Input/Output pin as an output - Register Manipulation: Directly writing to hardware registers to control the LED - Basic Delay Loop: Implementing a software delay for visual effect

Performance Optimization

For Lab 1, performance optimization is less critical than functional verification. However, understanding the direct register access versus library functions (e.g., HAL_GPIO_TogglePin) is a foundational concept for future optimization. Direct register access, as shown in the example, offers maximum control and minimal overhead.

Testing and Validation

Functional Tests

  • Power Test: Confirm stable power supply
  • LED Test: Verify LED toggles correctly
  • Connectivity Test: Ensure the debugger/programmer is recognized by the IDE

Debugging

  • Use the IDE’s debugger to step through the “Blinky LED” code
  • Observe register values and program counter movement
  • Confirm that the program executes as expected

Troubleshooting Guide

  • LED not blinking:
    • Check power supply
    • Verify GPIO pin configuration (input vs. output)
    • Ensure correct LED polarity
    • Debug code execution to see if the delay loop is running
  • Board not recognized by PC:
    • Reinstall USB drivers
    • Check USB cable and port
    • Verify board is powered
  • Compilation errors:
    • Check toolchain setup and compiler paths
    • Verify syntax and header file inclusions

Resources and Documentation

  • E155 Labs Overview
  • Lab Specs (Placeholder for actual lab specs)
  • Microcontroller Datasheet (e.g., STM32F4xx Reference Manual)
  • Board Schematic

Expected Outcomes

Upon successful completion of Lab 1, students will have a fully assembled and tested development board, a functional programming environment, and the ability to deploy basic embedded code. This lab lays the groundwork for more complex embedded systems projects.